import WxParse from '../../wxParse/wxParse.js';
import util from '../../utils/util.js';
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mode: 'widthFix',
    ttilsBanner:'../../images/banner.jpg',
    time:'2019-06-11',
    liulan:'../../images/liulan.png',
    liulanNum:'38',
    shoucang:'../../images/xin.png',
    fenxiang:'../../images/fenxiangTwo.png',
    zan:'../../images/zan2.png',
    zanNum:'6',
    wenzhangImg:'../../images/banner.jpg',
    hostUrl: app.globalData.hostUrl
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.info(options.school_id)
  },
  info: function (school_id){
    var that = this;
    wx.request({
      url: app.globalData.apiUrl + 'Index/school_info',
      data: {
        id: school_id
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        if (res.data != null) {
          WxParse.wxParse('Content', 'html', res.data.content, that, 5),

          that.setData({
            info:res.data
          })
        }
      }
    })
  },
  //收藏
  shoucang: function (e) {
    var userId = wx.getStorageSync('userId');
    // console.log(userId);
    // return ;
    if (wx.getStorageSync('userId') !== "") {
      wx.request({
        url: app.globalData.apiUrl + 'Index/collect',
        data: {
          // opt: 'getBanner',
          userId: userId,
          id: e.currentTarget.dataset.id,
          type: 'news',
        },
        header: {
          'content-type': 'application/json'
        },
        success: function (res) {
          console.log(res)
          if (res.data != null) {
            wx.showModal({
              title: '提示',
              content: res.data.message,
            })
          }
        }
      })
    } else {

      wx.showModal({
        title: '请先登录',
        content: 'icon',
      })
    }

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})